package com.ce.cases.hear.logic;

import java.util.Date;

import com.ce.cases.hear.dao.po.CaseSourceHear;
import com.ce.framework.datamaintain.dao.po.AbstractPO;
import com.ce.framework.datamaintain.implement.BaseDao;
import com.ce.framework.exception.AppException;
import com.ce.framework.util.GeneratorUUID;
import com.ce.framework.util.StringUtil;
import com.ce.sys.login.model.User;

public class CaseHearLogic implements ICaseHearLogic {
	private BaseDao basedao;
	public boolean dealHearReg(AbstractPO po){
		try {
			CaseSourceHear submitPo=(CaseSourceHear)po;
			 if(StringUtil.isNotBlank(po.getVcId())){
				 CaseSourceHear savePo = (CaseSourceHear) this.basedao.getPo(po.getClass().getName(), po.getVcId());
				savePo.setHearPerson(submitPo.getHearPerson());
				savePo.setHearDate(submitPo.getHearDate());
				savePo.setIsRetrial(submitPo.getIsRetrial());
				savePo.setIsCollegiate(submitPo.getIsCollegiate());
				savePo.setIsHearing(submitPo.getIsHearing());
				this.basedao.updatePo(savePo);
			  }else{
				  submitPo.setVcId(GeneratorUUID.generateUUID());
				  submitPo.setHearRegisterPerson(User.getUserName());
				  submitPo.setHearRegisterDeptid(User.getUserOrgId());
				  submitPo.setHearRegisterDate(new Date());
			    this.basedao.addPo(submitPo);
			  }
		} catch (AppException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public boolean dealFillReg(AbstractPO po) {
		try {
			CaseSourceHear submitPo=(CaseSourceHear)po;
			 if(StringUtil.isNotBlank(po.getVcId())){
				CaseSourceHear savePo = (CaseSourceHear) this.basedao.getPo(po.getClass().getName(), po.getVcId());
				savePo.setLocalAddedTax(submitPo.getLocalAddedTax());
				savePo.setLocalCostTax(submitPo.getLocalCostTax());
				savePo.setOperationTax(submitPo.getOperationTax());
				savePo.setConstructionTax(submitPo.getConstructionTax());
				savePo.setEntIncomeTax(submitPo.getEntIncomeTax());
				savePo.setPersonalIncomeTax(submitPo.getPersonalIncomeTax());  
                savePo.setResourceTax(submitPo.getResourceTax());
                savePo.setEducationTax(submitPo.getEducationTax());
                savePo.setIllegalMoney(submitPo.getIllegalMoney());
                savePo.setAdjustFillTax(submitPo.getAdjustFillTax());
                savePo.setNoFillTax(submitPo.getNoFillTax());
                savePo.setNoFillbackTax(submitPo.getNoFillbackTax());
                savePo.setAdjustIncome(submitPo.getAdjustIncome());
                savePo.setDeductPaidTax(submitPo.getDeductPaidTax());
                savePo.setRecoveredRefundedTax(submitPo.getRecoveredRefundedTax());
                savePo.setPunishmentCount(submitPo.getPunishmentCount());
                savePo.setFaKuanMoney(submitPo.getFaKuanMoney());
                savePo.setAddedFine(submitPo.getAddedFine());
                savePo.setIllegalTypeHearNum(submitPo.getIllegalTypeHearNum());
                savePo.setIllegalTypeHearName(submitPo.getIllegalTypeHearName());
				this.basedao.updatePo(savePo);
			  }else{
				  submitPo.setVcId(GeneratorUUID.generateUUID());
				  submitPo.setFillRegisterPerson(User.getUserName());
				  submitPo.setFillRegisterDeptid(User.getUserOrgId());
				  submitPo.setFillRegisterDate(new Date());
			    this.basedao.addPo(submitPo);
			  }
		} catch (AppException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public boolean dealIlegalReg(AbstractPO po) {
		try {
			CaseSourceHear submitPo=(CaseSourceHear)po;
			 if(StringUtil.isNotBlank(po.getVcId())){
				CaseSourceHear savePo = (CaseSourceHear) this.basedao.getPo(po.getClass().getName(), po.getVcId());
				savePo.setTransportCount(submitPo.getTransportCount());
				savePo.setTransportMoney(submitPo.getTransportMoney());
				savePo.setConstructionCount(submitPo.getConstructionCount());
				savePo.setConstructionMoney(submitPo.getConstructionMoney());
				savePo.setCommercialCount(submitPo.getCommercialCount());
				savePo.setCommercialMoney(submitPo.getCommercialMoney());
				savePo.setCateringCount(submitPo.getCateringCount());
				savePo.setCateringMoney(submitPo.getCateringMoney());
				savePo.setAddedTaxCount(submitPo.getAddedTaxCount());
				savePo.setAddedTaxMoney(submitPo.getAddedTaxMoney());
				savePo.setOtherCount(submitPo.getOtherCount());
				savePo.setOtherMoney(submitPo.getOtherMoney());
				savePo.setTotalCount(submitPo.getTotalCount());
				savePo.setTotalMoney(submitPo.getTotalMoney());
				this.basedao.updatePo(savePo);
			  }else{
				  submitPo.setVcId(GeneratorUUID.generateUUID());
				  submitPo.setIllegalRegisterPerson(User.getUserName());
				  submitPo.setIllegalRegisterDeptid(User.getUserOrgId());
				  submitPo.setIllegalRegisterDate(new Date());
			    this.basedao.addPo(submitPo);
			  }
		} catch (AppException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public boolean dealTrackReg(AbstractPO po) {
		try {
			CaseSourceHear submitPo=(CaseSourceHear)po;
			 if(StringUtil.isNotBlank(po.getVcId())){
				CaseSourceHear savePo = (CaseSourceHear) this.basedao.getPo(po.getClass().getName(), po.getVcId());
				savePo.setIsReconsideration(submitPo.getIsReconsideration());
				savePo.setIsProcedure(submitPo.getIsProcedure());
				savePo.setIsCompensation(submitPo.getIsCompensation());
				savePo.setCompensationMoney(submitPo.getCompensationMoney());
				this.basedao.updatePo(savePo);
			  }else{
				  submitPo.setVcId(GeneratorUUID.generateUUID());
				  submitPo.setTrackRegisterPerson(User.getUserName());
				  submitPo.setTrackRegisterDeptid(User.getUserOrgId());
				  submitPo.setTrackRegisterDate(new Date());
			    this.basedao.addPo(submitPo);
			  }
		} catch (AppException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public boolean dealJudicialReg(AbstractPO po) {
		try {
			CaseSourceHear submitPo=(CaseSourceHear)po;
			 if(StringUtil.isNotBlank(po.getVcId())){
				CaseSourceHear savePo = (CaseSourceHear) this.basedao.getPo(po.getClass().getName(), po.getVcId());
				savePo.setTransferNumber(submitPo.getTransferNumber());
				savePo.setTreatmentNumber(submitPo.getTreatmentNumber());
				savePo.setTreatmentResultNum(submitPo.getTreatmentResultNum());
				savePo.setTreatmentResultName(submitPo.getTreatmentResultName());
				this.basedao.updatePo(savePo);
			  }else{
				  submitPo.setVcId(GeneratorUUID.generateUUID());
				  submitPo.setJudicialRegisterPerson(User.getUserName());
				  submitPo.setJudicialRegisterDeptid(User.getUserOrgId());
				  submitPo.setJudicialRegisterDate(new Date());
			    this.basedao.addPo(submitPo);
			  }
		} catch (AppException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}
	public BaseDao getBasedao() {
		return basedao;
	}
	public void setBasedao(BaseDao basedao) {
		this.basedao = basedao;
	}
	
	

}
